﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MvvmLight1
{
    /// <summary>
    /// Interaction logic for BannerUserControl.xaml
    /// </summary>
    public partial class BannerUserControl : UserControl
    {
        public BannerUserControl()
        {
            InitializeComponent();
        }

        public ImageSource BannerSource
        {
            get { return (ImageSource)GetValue(BannerSourceProperty); }
            set { SetValue(BannerSourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for BannerSource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BannerSourceProperty =
            DependencyProperty.Register("BannerSource", typeof(ImageSource), typeof(BannerUserControl), new UIPropertyMetadata(OnImageSourcePropertyChanged));

        private static void OnImageSourcePropertyChanged(object sender, DependencyPropertyChangedEventArgs agrs)
        {
            var bannerControl = (BannerUserControl)sender;
            bannerControl.bannerImage.Source = (ImageSource)agrs.NewValue;
        }    

        public string BannerString
        {
            get { return (string)GetValue(BannerStringProperty); }
            set { SetValue(BannerStringProperty, value); }
        }

        // Using a DependencyProperty as the backing store for BannerString.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BannerStringProperty =
            DependencyProperty.Register("BannerString", typeof(string), typeof(BannerUserControl), new UIPropertyMetadata(OnStringPropertyChanged));

        private static void OnStringPropertyChanged(object sender, DependencyPropertyChangedEventArgs args)
        {
            var bannerControl = (BannerUserControl)sender;
            bannerControl.bannerLabel.Content = (string)args.NewValue;
        }
    }
}
